# eric7.MicroPython.MicroPythonGraphWidget

Module implementing the MicroPython diagram widget based on QtGraphs.

### Global Attributes

None

### Classes

MicroPythonGraphWidget | Class implementing the MicroPython diagram widget based on QtGraphs.
MicroPythonLineGraphWidget | Class implementing a widget embedding the line graph object.
MicroPythonLineGraphWidgetItem | Class implementing an object embedding the QML GraphsView.

### Functions

None

## MicroPythonGraphWidget

Class implementing the MicroPython diagram widget based on QtGraphs.

### Signals

dataFlood
  emitted to indicate, that too much data is received

### Derived from

QWidget

### Class Attributes

None

### Class Methods

None

### Methods

MicroPythonGraphWidget | Constructor
__addData | Private method to add a tuple of values to the graph.
__eraseData | Private slot to erase the graph and the stored raw data.
hasData | Public method to check, if the chart contains some valid data.
isDirty | Public method to check, if the chart contains unsaved data.
on_saveButton_clicked | Private slot to save the raw data to a CSV file.
preferencesChanged | Public slot to apply changed preferences.
processData | Public slot to process the raw data.
saveData | Public method to save the dialog's raw data.
shutdown | Public method to perform some shutdown actions.

### Static Methods

None

#### MicroPythonGraphWidget (Constructor)

MicroPythonGraphWidget(parent=None)

Constructor

parent (QWidget)
  reference to the parent widget

#### MicroPythonGraphWidget.__addData

__addData(values)

Private method to add a tuple of values to the graph.

values (tuple of int or float)
  tuple containing the data to be added

#### MicroPythonGraphWidget.__eraseData

__eraseData()

Private slot to erase the graph and the stored raw data.

#### MicroPythonGraphWidget.hasData

hasData()

Public method to check, if the chart contains some valid data.

Return:
  flag indicating valid data

Return Type:
  bool

#### MicroPythonGraphWidget.isDirty

isDirty()

Public method to check, if the chart contains unsaved data.

Return:
  flag indicating unsaved data

Return Type:
  bool

#### MicroPythonGraphWidget.on_saveButton_clicked

on_saveButton_clicked()

Private slot to save the raw data to a CSV file.

#### MicroPythonGraphWidget.preferencesChanged

preferencesChanged()

Public slot to apply changed preferences.

#### MicroPythonGraphWidget.processData

processData(data)

Public slot to process the raw data.

It takes raw bytes, checks the data for a valid tuple of ints or floats and adds the data to the graph. If the the length of the bytes data is greater than 1024 then a dataFlood signal is emitted to ensure eric can take action to remain responsive.

data (bytes)
  raw data received from the connected device via the main device widget

#### MicroPythonGraphWidget.saveData

saveData()

Public method to save the dialog's raw data.

Return:
  flag indicating success

Return Type:
  bool

#### MicroPythonGraphWidget.shutdown

shutdown()

Public method to perform some shutdown actions.

Up

## MicroPythonLineGraphWidget

Class implementing a widget embedding the line graph object.

### Derived from

QQuickWidget

### Class Attributes

None

### Class Methods

None

### Methods

MicroPythonLineGraphWidget | Constructor
shutdown | Public method to perform some shutdown actions.
widgetItem | Public method to get a reference to the graph view interface item.

### Static Methods

None

#### MicroPythonLineGraphWidget (Constructor)

MicroPythonLineGraphWidget(parent=None)

Constructor

parent (QWidget (optional))
  reference to the parent widget (defaults to None)

#### MicroPythonLineGraphWidget.shutdown

shutdown()

Public method to perform some shutdown actions.

#### MicroPythonLineGraphWidget.widgetItem

widgetItem()

Public method to get a reference to the graph view interface item.

Return:
  reference to the graph view interface item

Return Type:
  MicroPythonLineGraphWidgetItem

Up

## MicroPythonLineGraphWidgetItem

Class implementing an object embedding the QML GraphsView.

### Signals

graphsThemeChanged()
  signal to notify the graphs view about a theme change
lineSeriesChanged()
  signal to notify the graphs view about a change of the list of line series
xAxisChanged()
  signal to notify the graphs view about a change of the x-axis
yAxisChanged()
  signal to notify the graphs view about a change of the y-axis

### Derived from

QObject

### Class Attributes

QmlPropertyName
QmlSource
graphsTheme
lineSeries
xAxis
yAxis

### Class Methods

None

### Methods

MicroPythonLineGraphWidgetItem | Constructor
__adjustLineSeriesLength | Private method to adjust the line series to the maximum number of points set via the top level widget.
__updateAxis | Private method to adjust the axis ranges to the line values.
addData | Public method to add a tuple of values to the graph.
clear | Public slot to clear the graph and reset it.
getGraphsTheme | Public method to get a reference to the graphs theme object.
getLineSeries | Public method to get the list of line series objects to be shown by the QML view.
getXAxis | Public method to get a reference to the x-axis object.
getYAxis | Public method to get a reference to the y-axis object.
preferencesChanged | Public slot handling a change of configuration entries.
setGridVisible | Public slot to set the grid visibility.
setMaxPointsCount | Public slot to handle a change of the maximum number of points to be shown.
setSubGridVisible | Public slot to set the sub-grid visibility.
setWidget | Public method to associate this QML object with a given QQuick widget.

### Static Methods

None

#### MicroPythonLineGraphWidgetItem (Constructor)

MicroPythonLineGraphWidgetItem(parent=None)

Constructor

parent (QObject (optional))
  reference to the parent object (defaults to None)

#### MicroPythonLineGraphWidgetItem.__adjustLineSeriesLength

__adjustLineSeriesLength()

Private method to adjust the line series to the maximum number of points set via the top level widget.

#### MicroPythonLineGraphWidgetItem.__updateAxis

__updateAxis()

Private method to adjust the axis ranges to the line values.

#### MicroPythonLineGraphWidgetItem.addData

addData(values)

Public method to add a tuple of values to the graph.

It ensures there are the required number of line series, adds the data to the line series and updates the range of the chart so the chart displays nicely.

values (tuple of int or float)
  tuple containing the data to be added

#### MicroPythonLineGraphWidgetItem.clear

clear()

Public slot to clear the graph and reset it.

#### MicroPythonLineGraphWidgetItem.getGraphsTheme

getGraphsTheme()

Public method to get a reference to the graphs theme object.

Return:
  reference to the graphs theme object

Return Type:
  QGraphsTheme

#### MicroPythonLineGraphWidgetItem.getLineSeries

getLineSeries()

Public method to get the list of line series objects to be shown by the QML view.

Return:
  list of line series objects

Return Type:
  QLineSeries

#### MicroPythonLineGraphWidgetItem.getXAxis

getXAxis()

Public method to get a reference to the x-axis object.

Return:
  reference to the x-axis object

Return Type:
  QValueAxis

#### MicroPythonLineGraphWidgetItem.getYAxis

getYAxis()

Public method to get a reference to the y-axis object.

Return:
  reference to the y-axis object

Return Type:
  QValueAxis

#### MicroPythonLineGraphWidgetItem.preferencesChanged

preferencesChanged()

Public slot handling a change of configuration entries.

#### MicroPythonLineGraphWidgetItem.setGridVisible

setGridVisible(visible)

Public slot to set the grid visibility.

visible (bool)
  flag indicating the grid visibility

#### MicroPythonLineGraphWidgetItem.setMaxPointsCount

setMaxPointsCount(value)

Public slot to handle a change of the maximum number of points to be shown.

value (int)
  maximum number of points

#### MicroPythonLineGraphWidgetItem.setSubGridVisible

setSubGridVisible(visible)

Public slot to set the sub-grid visibility.

visible (bool)
  flag indicating the sub-grid visibility

#### MicroPythonLineGraphWidgetItem.setWidget

setWidget(widget)

Public method to associate this QML object with a given QQuick widget.

widget (QQuickWidget)
  reference to the embedding QQuick widget

Up